package com.jdk.learn.juc2.thread.excrise;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 类功能描述:
 *
 * @author bgt
 * @version V1.0
 * @since 2019-03-01 13:55
 */
public class Pool {
    public static void main(String[] args) throws InterruptedException {

        ExecutorService executorService = Executors.newFixedThreadPool(2);
        Thread mqconsumer = new Thread(() -> {
            System.out.println("main begin");
            executorService.execute(() -> {
                try {
                    System.out.println("sub begin");
                    Thread.sleep(2000);
                    System.out.println("sub end ");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
            System.out.println("main end");
        });


        mqconsumer.start();
        System.out.println("Alive result is_Alive:"+mqconsumer.isAlive()+"---");
        mqconsumer.join();
        System.out.println("Alive result is_Alive:"+mqconsumer.isAlive());

    }
}
